package org.films.domain;

import org.films.domain.FilmDataOnDemand;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

privileged aspect FilmIntegrationTest_Roo_IntegrationTest {
    
    declare @type: FilmIntegrationTest: @RunWith(SpringJUnit4ClassRunner.class);    
    
    declare @type: FilmIntegrationTest: @ContextConfiguration(locations = "classpath:/META-INF/spring/applicationContext.xml");    
    
    @Autowired    
    private FilmDataOnDemand FilmIntegrationTest.dod;    
    
    @Test    
    public void FilmIntegrationTest.testCountFilms() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        long count = org.films.domain.Film.countFilms();        
        org.junit.Assert.assertTrue("Counter for 'Film' incorrectly reported there were no entries", count > 0);        
    }    
    
    @Test    
    public void FilmIntegrationTest.testFindFilm() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        java.lang.Long id = dod.getRandomFilm().getId();        
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to provide an identifier", id);        
        org.films.domain.Film obj = org.films.domain.Film.findFilm(id);        
        org.junit.Assert.assertNotNull("Find method for 'Film' illegally returned null for id '" + id + "'", obj);        
        org.junit.Assert.assertEquals("Find method for 'Film' returned the incorrect identifier", id, obj.getId());        
    }    
    
    @Test    
    public void FilmIntegrationTest.testFindAllFilms() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        long count = org.films.domain.Film.countFilms();        
        org.junit.Assert.assertTrue("Too expensive to perform a find all test for 'Film', as there are " + count + " entries; set the findAllMaximum to exceed this value or set findAll=false on the integration test annotation to disable the test", count < 250);        
        java.util.List<org.films.domain.Film> result = org.films.domain.Film.findAllFilms();        
        org.junit.Assert.assertNotNull("Find all method for 'Film' illegally returned null", result);        
        org.junit.Assert.assertTrue("Find all method for 'Film' failed to return any data", result.size() > 0);        
    }    
    
    @Test    
    public void FilmIntegrationTest.testFindFilmEntries() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        long count = org.films.domain.Film.countFilms();        
        if (count > 20) count = 20;        
        java.util.List<org.films.domain.Film> result = org.films.domain.Film.findFilmEntries(0, (int)count);        
        org.junit.Assert.assertNotNull("Find entries method for 'Film' illegally returned null", result);        
        org.junit.Assert.assertEquals("Find entries method for 'Film' returned an incorrect number of entries", count, result.size());        
    }    
    
    @Test    
    @Transactional    
    public void FilmIntegrationTest.testFlush() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        java.lang.Long id = dod.getRandomFilm().getId();        
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to provide an identifier", id);        
        org.films.domain.Film obj = org.films.domain.Film.findFilm(id);        
        org.junit.Assert.assertNotNull("Find method for 'Film' illegally returned null for id '" + id + "'", obj);        
        boolean modified =  dod.modifyFilm(obj);        
        java.lang.Integer currentVersion = obj.getVersion();        
        obj.flush();        
        org.junit.Assert.assertTrue("Version for 'Film' failed to increment on flush directive", obj.getVersion() > currentVersion || !modified);        
    }    
    
    @Test    
    @Transactional    
    public void FilmIntegrationTest.testMerge() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        java.lang.Long id = dod.getRandomFilm().getId();        
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to provide an identifier", id);        
        org.films.domain.Film obj = org.films.domain.Film.findFilm(id);        
        org.junit.Assert.assertNotNull("Find method for 'Film' illegally returned null for id '" + id + "'", obj);        
        boolean modified =  dod.modifyFilm(obj);        
        java.lang.Integer currentVersion = obj.getVersion();        
        obj.merge();        
        obj.flush();        
        org.junit.Assert.assertTrue("Version for 'Film' failed to increment on merge and flush directive", obj.getVersion() > currentVersion || !modified);        
    }    
    
    @Test    
    @Transactional    
    public void FilmIntegrationTest.testPersist() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        org.films.domain.Film obj = dod.getNewTransientFilm(Integer.MAX_VALUE);        
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to provide a new transient entity", obj);        
        org.junit.Assert.assertNull("Expected 'Film' identifier to be null", obj.getId());        
        obj.persist();        
        obj.flush();        
        org.junit.Assert.assertNotNull("Expected 'Film' identifier to no longer be null", obj.getId());        
    }    
    
    @Test    
    @Transactional    
    public void FilmIntegrationTest.testRemove() {    
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to initialize correctly", dod.getRandomFilm());        
        java.lang.Long id = dod.getRandomFilm().getId();        
        org.junit.Assert.assertNotNull("Data on demand for 'Film' failed to provide an identifier", id);        
        org.films.domain.Film obj = org.films.domain.Film.findFilm(id);        
        org.junit.Assert.assertNotNull("Find method for 'Film' illegally returned null for id '" + id + "'", obj);        
        obj.remove();        
        org.junit.Assert.assertNull("Failed to remove 'Film' with identifier '" + id + "'", org.films.domain.Film.findFilm(id));        
    }    
    
}
